<template>
  <el-dialog name="LoginShade" title="登陆" :visible.sync="dialogLogin" center width="400px">
    <div class="s-loginshade">
      <el-form ref="form" label-width="80px">
        <el-form-item label="账号:">
          <el-input v-model="username"></el-input>
        </el-form-item>
        <el-form-item label="密码:">
          <el-input v-model="password"></el-input>
        </el-form-item>
        <el-form-item class="login-sub-content">
          <el-button type="primary" @click="loginSubmin" v-clickReTime="5000">登陆</el-button>
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "LoginShade",
  data() {
    return {
      dialogLogin: false,
      username: "",
      password: "111111",
    };
  },
  methods: {
    loginSubmin() {
      let _this = this;
      let prams = {
        userName: this.username,
        passWord: this.password,
      };
      if (this.username == "") {
        this.$message("请输入账号");
        return;
      }
      if (this.password == "") {
        this.$message("请输入密码");
        return;
      }
      this.$http
        .post("iaiqsmde9fea569965ed56ab98ea0501752fe631902841e/login", prams)
        .then(res => {
          let { success, token, code } = res;
          if (success && code == 0 && token && token != "") {
            su.cook.setcookie("token", token);
            su.cook.setcookie("username", this.username);
            _this.$message({
              message: "登录成功",
              type: false,
            });
            _this.dialogLogin = false;
            setTimeout(() => {
              location.href = "./";
            }, 800);
          }
        })
        .catch(err => {
          console.log(err.message || "数据异常");
        });
    },
  },
};
</script>
